/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package GUI;

import Model.ActorEvent;
import Model.ActorListener;

/**
 *
 * @author Snowangelic
 */
public class ActorView implements ActorListener {
    Layer actorLayer;
    int xOffset;
    int yOffset;

    ActorView(Layer actorLayer){
        this.actorLayer=actorLayer;
        xOffset=0;
        yOffset=0;
    }

    ActorView(Layer actorLayer, int x,int y){
        this.actorLayer=actorLayer;
        xOffset=x;
        yOffset=y;
    }

    public void actorMoved(ActorEvent e){
        /*
        int oldX=(int) (e.getSource().getOldX()-e.getSource().getRayon()-xOffset);
        int oldY=(int) (e.getSource().getOldY()-e.getSource().getRayon()-yOffset);
        actorLayer.addLayerEvent(new LayerEvent(oldX,oldY,pooUtils.TransparentImage.getTransparentImage()));
        */
        actorImageChanged(e);
    }



    public void actorDied(ActorEvent e) {
        actorLayer.hide();
    }

    void setOffset(int x, int y) {
        xOffset=x;
        yOffset=y;
    }

    public void actorImageChanged(ActorEvent e) {
        int xPos=(int) (e.getSource().getX()-e.getSource().getImage().getWidth()/2-xOffset);
        int yPos=(int) (e.getSource().getY()-e.getSource().getImage().getHeight()/2-yOffset);
        actorLayer.addLayerEvent(new LayerEvent(xPos,yPos,e.getSource().getImage()));
    }
}
